//test a la place de effEmployesched pour les srcoolform 
package planclient;

import graphique.VueEmployeJour;

import javax.inject.Inject;
import javax.annotation.PostConstruct;

import modele.Employe;
import modele.Employes;
import modele.IntervalleTemporellesFactory;

import org.eclipse.draw2d.MouseEvent;
import org.eclipse.draw2d.MouseListener;
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
import org.eclipse.gef.EditPolicy;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.ScrolledForm;
import org.eclipse.ui.forms.widgets.Section;

public class AffEmployeAgenda implements SelectionListener {
	private Employe emp;
	ScrolledForm form;
	private VueEmployeJour canvas;
	private IntervalleTemporellesFactory listeIntervalle;
	
	@Inject
	public AffEmployeAgenda() {
		//TODO Your code here
	}
	
	@PostConstruct
	public void postConstruct(Composite parent,MPart part) {
		//TODO Your code here
		
		 emp = (Employe) part.getObject();
		 

		 FormToolkit toolkit = new FormToolkit(parent.getDisplay());
		   form = toolkit.createScrolledForm(parent);

		  form.getHorizontalBar().addSelectionListener(this);
		  form.getVerticalBar().addSelectionListener(this);

			
			
		   /* form.setText("Agenda de "+emp.getNom());
		    form.getBody().setLayout(new GridLayout());
		    //toolkit.createButton(form.getBody(), "Checkbox", SWT.CHECK);
		    
		   
		    // Lets make a layout for the first section of the screen
		    GridLayout  layout = new GridLayout();
		    layout.numColumns = 1;
		    layout.marginWidth = 0;
		    layout.marginHeight = 0;
		    
		    
		    // Creating the Screen
		    Label label = new Label(form.getBody(), SWT.NONE);
			 FontData fontData = label.getFont().getFontData()[0];

			 Font font = new Font(parent.getDisplay(), new FontData(fontData.getName(), fontData
					    .getHeight(), SWT.ITALIC));
			 label.setFont(font);
			 label.setText("Bold Label");;*/
		    
		    
			 //Set sze of widget
		    canvas = new VueEmployeJour(form.getBody(),SWT.NONE);

			 final GridData data = new GridData();
			 data.widthHint = canvas.getSize().x;
			 data.heightHint =canvas.getSize().y;
			 canvas.setLayoutData(data);
			 
			 // GEt intervalle d'apres employe passer en argument
			 listeIntervalle = IntervalleTemporellesFactory.Factory();
			 canvas.addIntervalles(listeIntervalle);
			 
			 
			 
						 
	}

	@Override
	public void widgetSelected(SelectionEvent e) {
		// TODO Auto-generated method stub
		//System.out.println(form.getHorizontalBar().getMinimum()+ " " + form.getHorizontalBar().getMaximum());
		//System.out.println(form.getOrigin().y);
		//System.out.println(form.getVerticalBar().getMinimum()+ " " + form.getVerticalBar().getMaximum());
		//System.out.println(form.getOrigin().y);
		canvas.setVerticalUpdate(form.getOrigin().y);
		
	}

	@Override
	public void widgetDefaultSelected(SelectionEvent e) {
		// TODO Auto-generated method stub
		
	}

	
	
	
	
}